from django.shortcuts import render, HttpResponse
from .modelform import UserModelForm

from django.views import View


# Create your views here.


# def register(request):
# usermodelform = UserModelForm()
# return render(request, 'register.html', {'form': usermodelform})

class register(View):
    def get(self, request):
        usermodelform = UserModelForm()
        return render(request, 'app01/register.html', {'form': usermodelform})

    def post(self, request):
        user_reg_form = UserModelForm(request.POST)
        if user_reg_form.is_valid():
            user_reg_form.save()
            return HttpResponse('注册成功')
        usermodelform = UserModelForm()
        return render(request, 'app01/register.html', {'form': usermodelform})
